<%--
 *  File:    OrgSplitConfiguration.jsp
 *  @Author: jackwang
 *  Date:    2012/07/02
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>


<% //--------------------------------------  variant and initialization --%>
<%
    Category cat = Category.getInstance("jsp.OrgSplitConfiguration");
	String strModuleName = "CM";
 	String strTableName = "v_zylsplitorgname";
 	String privilegeCode = "E0166";   
    String contextPath = request.getContextPath(); 
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<iframe name="summaryfrm"  scrolling="no" src='<%=contextPath %>/tdr/datatypein/OrgSelectPop.jsp?maxitem=8&globalpccode=3&<%= OvalTools.randomURL() %>' frameborder="0" style="position:absolute; top:0px; left:0px; display:none;border:#909eff 1px solid;"></iframe>
<head>
<title></title>
<PageFlow:CheckPageFlow pageName="p_zylsplitorgname"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/summary.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector searchresults = (Vector)pageContext.getAttribute("searchresults");
	HashMap userinfo = (HashMap)session.getAttribute("userinfo");
  	if(searchresults == null)searchresults = new Vector();
%>
<script language="JavaScript" >

function page_summary(actionvalue,orderbyname){
  	 var editform = summaryPrepare(cform,actionvalue,orderbyname);
 	 editform.action = "OrgSplitConfiguration.jsp?<%= OvalTools.randomURL() %>";
 	 editform.target = "_self";
 	 isRunning = true;
 	 editform.submit();
}

function page_add(){
	 if(!checkForm(document.cform)) return;
	 cform.actionname.value = "add";
  	 cform.target = "_self";
  	 isRunning = true;
  	 cform.submit();
}

function page_save(){
	cform.actionname.value = "save";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}

function page_delete(){
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}

function allcheckselect(){
	var allcheck = cform.allcheck.checked;
	var alldatafile = document.getElementsByName('deleteids');
	var length = alldatafile.length;
	if(allcheck){
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = true;
		}
	}else{
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = false;
		}	
	}
}
var isHidden;
function frm_select(e,index){
	idx=index;
	isHidden = "block";
	var _target = getPosition(e);
    var _obj = document.getElementById("summaryfrm");
    _obj.style.left = _target.x;
    _obj.style.top = _target.y + e.clientHeight;
    _obj.style.height="250px";
    _obj.style.width="530px";
    _obj.style.zIndex = 5000;
    _obj.style.display = "block";
	var strUrl = "";	
	//strUrl = "<%=contextPath %>/tdr/datatypein/OrgSelectPop.jsp?maxitem=8&globalpccode=3&<%= OvalTools.randomURL() %>";
    //document.summaryfrm.location.href = strUrl;
}
function getPosition(e) {
        var left = 0;
        var top = 0;
        while (e.offsetParent) {
            left += e.offsetLeft + (e.curentStyle? (parseInt(e.curentStyle.borderLeftWidth).NaN0()):0);
            top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
            e = e.offsetParent;
        }
        left += e.offsetLeft + (e.curentStyle ? (parseInt(e.curentStyle.borderLeftWidth)).NaN0() : 0);
        top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
        return {x:left, y:top};
}
function closeItemSelect(evt)
{
	var _obj = document.getElementById("summaryfrm");
	if(isHidden == "block"){
		isHidden = "none";
	}else{
		_obj.style.display = "none";
	}
	evt = evt || window.event;
        var _target = evt.target || evt.srcElement;
        if (!_target.getAttribute("Author") && _target != inputObj && _target != targetObj) {
            getObjById("Calendar").style.display = "none";
            getObjById("CalendarFrm").style.display = "none";
        }
}

function hiddenFrm(){
	document.getElementById("summaryfrm").style.display = "none";
}

document.onclick=closeItemSelect;   

var idx;

function setOrg(id,name,code)
{
	//eval('document.cform.orgid'+idx).value = id;
	eval('document.cform.orgcode'+idx).value = code;
	eval('document.cform.orgname'+idx).value = name;
	hiddenFrm();
}

</script>

</head>
<body>
<%-- //--------------------------------------  page location --%>

<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"  target="_self">
    <custom:hidden property="pagename" value="p_zylsplitorgname"/>
    <input type="hidden" name="actionname">
	<input type="hidden" name="numrows" value="<%=searchresults.size() %>">
	<custom:hidden property="userid" />
		<%@ include file="/inc/PageLocation.inc" %>
	<table width="100%" cellspacing="0" border="0" cellpadding="0">
	  	<tr>
	     	<td >
	    <table width="100%" border="0" cellspacing="0">
        <tr>
          <td class="summary_top" width="10%" colspan="3"></td>
        </tr>
        <%@ include file="/inc/SummarySearch.inc" %>
      </table>
	     	</td>
	    </tr>
	 
	    <tr> 
		    <td> 
		      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" >
		        <tr class="deepblue-left">
				  <td width="1%" class="title_center"><input type="checkbox" name="allcheck" class="normalradio" onclick="allcheckselect();"></td>
		          <td class="title_left" width="54%"><a href="javascript:page_summary('orderby','orgname')"><%= label.getLabelName("L_Dealer") %></a></td>
		          <td class="title_left" width="45%px"><a href="javascript:page_summary('orderby','dealercolumnname')"><%= label.getLabelName("L_DealerColumnName") %></a></td>
		        </tr>
		        <%
	            	int i = 0;
	             	String strClassType = new String();
	          	%>
		         <logic:iterate id="onerow" collection="<%= searchresults %>" indexId="idx"> 
		           	<%
		            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
		            	if(i%2 == 1)
		            	{
		              		strClassType = "td-listrom";
		            	}else{
		              		strClassType = "";
		            	}
		            	i++;
		            	
		          	%>
		          	<tr id="tr<%=idx %>" class="none">
		          		<td id="td" class="title_left" >
		                    <input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull( tempMap.get("zylsplitorgnameid") )%>" class="checkbox">
		            		<custom:hidden name="onerow" property="zylsplitorgnameid" colIndex="<%=idx %>"/>
		            	</td>
						<td class="title_left">
							<!--<custom:hidden name="onerow" property="orgid" colIndex="<%=idx %>"/>
				           	--><custom:text name="onerow" property="orgcode" readonly="true" colIndex="<%=idx %>"/>
				           	<a onclick="frm_select(this,<%= idx%>);"><custom:button type="3" value="*"/></a>
				           	<custom:text name="onerow" property="orgname" size='50' readonly="true" colIndex="<%=idx %>"/>
						</td> 
						<td class="title_left">
							<custom:text name="onerow" property="dealercolumnname" size='50' label="L_DealerColumnName" colIndex="<%=idx %>"/>
						</td>   
		     	 </logic:iterate>
		     	 <tr class="none">
		           <td>&nbsp;</td>
		           <td class="title_left">
					<!--<custom:hidden name="details"  property="orgid" />
					--><custom:text  property="orgcode" name="details" command="notnull" label="L_Dealer" readonly="true"/>
					<a onclick="frm_select(this,'')"><custom:button type="3" value="*"/></a>
					<custom:text  property="orgname" name="details" command="notnull" size='50' label="L_Dealer" readonly="true"/>
		           </td> 
		            <td class="title_left">
		           	<custom:text property="dealercolumnname" name="details" command="notnull" size='50' label="L_DealerColumnName"/>
	               </td>
			     </tr>
		      <%@ include file="/inc/SummaryAction.inc" %>
		      </table>	      
		      </td>
		      </tr>
		      <tr>
		      <td>
		      
		      <table width="100%" cellspacing="0" cellpadding="0">
		        <tr> 
		          <td class="summary_top"></td>
		        </tr>
		        <tr>
				     <td class="td_center">
						<a onclick="page_add()"><custom:button type="2" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a>
						<%if(searchresults.size() >0 ){%>
						<a onclick="page_save()"><custom:button type="2" label="L_Save" imgsrc="delete.gif" border="0" style="width:60"/></a>
						<a onclick="page_delete()"><custom:button type="2" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
						<%} %>
					 </td>
				</tr>
		      </table>
		    </td>
	  </tr>
	</table>
</form>
</body>
</html>
